package gui.modelos;

import java.util.ArrayList;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import vo.Applicant;

public class ApplicantTableModel extends AbstractTableModel {

    private List<Applicant> applicants;

    public static final int NAME = 0;

    public ApplicantTableModel() {
        applicants = new ArrayList<Applicant>();
    }

    public int getColumnCount() {
        return 1;
    }

    public int getRowCount() {
        return applicants.size();
    }

    public String getColumnName(int coluna) {
        switch (coluna) {
        case NAME:
            return "Name";
        }
        return "";
    }

    public Object getValueAt(int linha, int coluna) {
        Applicant titulo = get(linha);
        switch (coluna) {
        case NAME:
            return titulo.getName();
        }
        return null;
    }

    private Applicant get(int linha) {
        return applicants.get(linha);
    }

    /**
     * @return the applicants
     */
    public List<Applicant> getApplicants() {
        return applicants;
    }

    /**
     * @param applicants the applicants to set
     */
    public void setApplicants(List<Applicant> applicants) {
        this.applicants = applicants;
        fireTableDataChanged();
    }

}
